package config

import (
	"background/utilx/dbx"
	"background/utilx/timex"
	"time"
)

type ServerConf struct {
	Name      string
	Port      int
	DataBase  map[string]dbx.DataBase
	JWTConfig JWTConfig `json:"jwt"`
}
type RedisConfig struct {
	Expire int    `json:"expire_duration" yaml:"expire_duration"`
	Unit   string `json:"unit" yaml:"unit"`
}
type JWTConfig struct {
	RedisConfig
	PrivateKey string
	PublicKey  string
	SigningKey string
}

func (r *JWTConfig) Duration() time.Duration {
	if r.Expire == 0 {
		r.Expire = 360
	}
	return timex.TimeDuration(r.Expire, r.Unit)
}
func (r *RedisConfig) Duration() time.Duration {
	if r.Expire == 0 {
		r.Expire = 360
	}
	return timex.TimeDuration(r.Expire, r.Unit)
}
